#include <bits/stdc++.h>
using namespace std;
#define int long long

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    map<int, int> mp;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    if(a[0] == a[n - 1]) {
        if(mp[a[0]] >= k) {
            cout << "YES" << endl;
            return;
        }
    }
    int cnt1 = 1, cnt2 = 1;
    if(k == 1) {
        cout << "YES" << endl;
        return ;
    }
    int p1 = -1, p2 = -1;
    for(int i = 1; i < n; i++) {
        if(a[i] == a[0]) cnt1++;
        if(cnt1 == k) {
            p1 = i;
            break;
        }
    }
    for(int i = n - 2; i >= 0; i--) {
        if(a[i] == a[n - 1]) cnt2++;
        if(cnt2 == k) {
            p2 =i;
            break;
        }
    }
    if(p1 == -1 || p2 == -1 || p1 >= p2){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
}

signed main() {
    int t;
    cin >> t;
    while(t--) solve();
    return 0;
}